<template>
	<view class='cu-modal modal-bottom' :class='{show: show}'>
		<view class='modal'>
			<view class='head'>
				<text class='title'>{{type=='other'?'发放列表':'授权列表'}}</text>
				<text class='close cuIcon-close' @click='handleClose'></text>
			</view>
			<view class='project-box'>
				<view class='label'>
					<image class='icon' src='https://qiyeji.oss-cn-beijing.aliyuncs.com/pet/xiangmu.png'></image>
					<text>服务项目：</text>
				</view>
				<view class='value'>{{item.name}}</view>
			</view>
			<view class='table-box'>
				<view class='t-head'>
					<view class='t-cel name'>{{type=='other'?'客户名称':'服务商'}}</view>
					<view class='t-cel date'>{{type=='other'?'发放时间':'授权时间'}}</view>
					<view class='t-cel num text-right'>{{type=='other'?'核销数量/发放数量':'已发放/授权次数'}}</view>
				</view>
				<view class='t-body'>
					<view class='t-item' v-for='(item,index) in list' :key="index">
						<view class='t-cel name text-cut2'>{{item.bizName}}</view>
						<view class='t-cel date'>{{item.createTime}}</view>
						<view class='t-cel num text-right'>{{item.useNum}}/{{item.total}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getIssueList} from "@/api/pet/service/saler.js"
	export default {
		data() {
			return {
				show: false,
				type:'', //other 其他服务商发放记录  my 我的
				item:{},
				list:[],
			}
		},
		methods: {
			handleOpen(data) {
				this.type = data.type
				this.item = data.item
				this.show = true;
				this.getList()
			},
			getList(){
				let params = {}
				if(this.type == 'other'){
					params = {
						serveId:this.item.id,
						issueId:this.item.issueId,
						type:'USER'
					}
				}else{
					params = {
						serveId:this.item.id,
						type:'MCH'
					}
				}
				getIssueList(params).then(res=>{
					this.list = res
				})
			},
			handleClose() {
				this.show = false;
			}
		
		}
	}
</script>

<style scoped lang="scss">
	.modal {
		width: 100%;
		position: absolute;
		left: 0;
		bottom: 0;
		background: #FFFFFF;
		padding: 0 0 76rpx 0;
		text-align: left;
		border-radius: 40rpx 40rpx 0rpx 0rpx;
		
		.head {
			text-align: center;
			font-weight: 500;
			font-size: 30rpx;
			color: var(--h1Color);
			padding: 32rpx 0 64rpx 0;
			position: relative;
			
			.close {
				position: absolute;
				top:  32rpx;
				right: 32rpx;
			}
		}
		
		.project-box {
			padding: 0 40rpx 64rpx 40rpx;
			display: flex;
			font-size: 30rpx;
			color: var(--h1Color);
			line-height: 42rpx;
			
			.label {
				display: flex;
				align-items: center;
				margin-right: 30rpx;
				height: max-content;
				
				.icon {
					width: 26rpx;
					height: 26rpx;
					margin-right: 12rpx;
				}
			}
			
			.value {
				flex: 1;
			}
		}
		
		.table-box {
			width: 718rpx;
			margin-left: 16rpx;
			border: 2rpx solid #EEEEEE;
			
			.t-cel {
				font-size: 26rpx;
				text-align: left;
				
				&.text-right {
					text-align: right;
				}
			}
			
			.t-head, .t-body {
				.name {
					width: 196rpx;
					margin-right: 20rpx;
				}
				
				.date {
					width: 242rpx;
				}
				
				.num {
					flex: 1;
				}
			}
			
			.t-head {
				display: flex;
				height: 85rpx;
				background: #F8F8F8;
				padding: 0 20rpx;
				font-weight: 600;
				align-items: center;
			}
			
			.t-body {
				max-height: 700rpx;
				overflow-y: scroll;
				
				.t-item {
					border-top: 2rpx solid #EEEEEE;
					height: 96rpx;
					display: flex;
					align-items: center;
					padding: 0 20rpx;
				}
			}
		}
		
	}
</style>